extends "res://ui/msgBase/msgBase.gd"

onready  var txt = $RichTextLabel
var talent = null
var base = globalData.infoDs["g_azurlaneBase"]
func _ready():
	pass

func init(talent):
	popup()
	self.talent = talent
	upInfo()
var lvP = [1, 1, 1, 1, 1]
func upInfo():
	if talent.lv < 5:
		var s = talent.info + "\n"
		s += "升级后\n"
		talent.lv += 1
		s += talent.info + "\n"
		talent.lv -= 1
		s += "升级花费：%d 至纯晶钻" % [lvP[talent.lv]]
		txt.bbcode_text = s
		upP()
	else:
		upP()
		txt.bbcode_text = "满级了！无法再升级"
		$Button.hide()

func _on_Button_pressed():
	if talentData.subP(lvP[talent.lv]):
		talent.lv += 1
		talentData.infoDs[talent.id].lv += 1
		talentData.saveInfo()
		sys.newBaseMsg("信息", "升级成功")
		upInfo()
	else:
		sys.newBaseMsg("信息", "至纯晶钻不足，通关游戏可获得至纯晶钻")

func _on_Button2_pressed():
	queue_free()

func upP():
	$Label.text = "至纯晶钻：%d" % base.getSetting("diamonds", 0)

